@vezham/icons-vue 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE +32 -0
- package/README.md +226 -0
- package/package.json +24 -0
- package/scripts/build.cjs +504 -0
- package/src/createIcon.d.ts +30 -0
- package/src/createIcon.js +66 -0
- package/src/icons/.gitkeep +1 -0
- package/tsconfig.json +17 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @vezham/icons-vue
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4bc7ae2`](https://github.com/vezham/reicon/commit/4bc7ae21342fe26c90359bc0d5cbb74258b32fe7) Thanks [@vx-vigneshwaran](https://github.com/vx-vigneshwaran)! - ver bump
|
|
8
|
+
|
|
9
|
+
## 1.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`345a93a`](https://github.com/vezham/reicon/commit/345a93aa6f5a5b7f0d4598a0708eb24dd704046a) Thanks [@vx-vigneshwaran](https://github.com/vx-vigneshwaran)! - ver bump
|
|
14
|
+
|
|
15
|
+
## 1.0.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`ccfadd2`](https://github.com/vezham/reicon/commit/ccfadd29b3031f81cc6986d9e2ff084eca798c81) Thanks [@vx-vigneshwaran](https://github.com/vx-vigneshwaran)! - init test
|
package/LICENSE
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
Attribution:
|
|
4
|
+
Creator / Maintainer : Vezham Technologies Private Limited
|
|
5
|
+
Original Author : REICON
|
|
6
|
+
Licensor : Vezham Technologies Private Limited
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 REICON.
|
|
9
|
+
Copyright (c) 2025–present Vezham Technologies Private Limited. All rights reserved.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
MIT License
|
|
14
|
+
|
|
15
|
+
Copyright (c) 2025 REICON
|
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
in the Software without restriction, including without limitation the rights
|
|
19
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
copies or substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://reicon.dev">
|
|
3
|
+
<img src="https://reicon.dev/readme-banner.png" alt="Reicon Vue — SVG Icon Library for Vue 3" width="100%" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://npmjs.com/package/reicon-vue"><img src="https://img.shields.io/npm/v/reicon-vue?color=black&label=npm" alt="npm version" /></a>
|
|
9
|
+
<a href="https://npmjs.com/package/reicon-vue"><img src="https://img.shields.io/npm/dm/reicon-vue?color=black&label=downloads" alt="npm downloads" /></a>
|
|
10
|
+
<a href="https://github.com/dqev/reicon/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-black" alt="MIT License" /></a>
|
|
11
|
+
<a href="https://reicon.dev"><img src="https://img.shields.io/badge/docs-reicon.dev-black" alt="Documentation" /></a>
|
|
12
|
+
<a href="https://github.com/dqev/reicon"><img src="https://img.shields.io/badge/github-dqev/reicon-black" alt="GitHub" /></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<h1 align="center">Reicon Vue</h1>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<b>2674+ pixel-perfect SVG icons</b> • Outline & Filled weights • Vue 3 component wrapper • Zero dependencies • MIT Licensed
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="#install">Install</a> •
|
|
23
|
+
<a href="#usage">Usage</a> •
|
|
24
|
+
<a href="#props">Props</a> •
|
|
25
|
+
<a href="#tree-shaking">Tree-shaking</a> •
|
|
26
|
+
<a href="#icon-names">Icon Names</a> •
|
|
27
|
+
<a href="#typescript">TypeScript</a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
**Reicon Vue** is the official Vue 3 package for <a href="https://reicon.dev">Reicon</a> — a free, open-source SVG icon library featuring 2674+ handcrafted, grid-aligned icons. Every component is tree-shakeable, fully TypeScript-ready, and ships with zero dependencies.
|
|
31
|
+
|
|
32
|
+
| 🔗 Resource | Link |
|
|
33
|
+
|---|---|
|
|
34
|
+
| 🌐 Website & icon browser | [reicon.dev](https://reicon.dev) |
|
|
35
|
+
| 📖 Documentation | [reicon.dev/docs](https://reicon.dev/docs) |
|
|
36
|
+
| 📦 Core package (vanilla JS) | [reicon](https://npmjs.com/package/reicon) |
|
|
37
|
+
| 🎨 Figma plugin | [reicon.dev/docs/figma](https://reicon.dev/docs/figma) |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm i reicon-vue
|
|
45
|
+
# or
|
|
46
|
+
bun add reicon-vue
|
|
47
|
+
# or
|
|
48
|
+
yarn add reicon-vue
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
<details>
|
|
52
|
+
<summary><b>Requirements</b></summary>
|
|
53
|
+
|
|
54
|
+
- **Vue** ≥ 3.0 (Composition API)
|
|
55
|
+
- No other dependencies required.
|
|
56
|
+
|
|
57
|
+
</details>
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
|
|
63
|
+
### Basic
|
|
64
|
+
|
|
65
|
+
```vue
|
|
66
|
+
<script setup>
|
|
67
|
+
import { Home, ShieldCheck, AltArrowDown } from 'reicon-vue';
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<template>
|
|
71
|
+
<div>
|
|
72
|
+
<Home />
|
|
73
|
+
<ShieldCheck :size="32" color="#d97757" />
|
|
74
|
+
<AltArrowDown weight="Filled" />
|
|
75
|
+
</div>
|
|
76
|
+
</template>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Weights
|
|
80
|
+
|
|
81
|
+
Every icon ships in two weights — **Outline** (default) and **Filled**:
|
|
82
|
+
|
|
83
|
+
```vue
|
|
84
|
+
<Home /> <!-- Outline (default) -->
|
|
85
|
+
<Home weight="Filled" /> <!-- Filled -->
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Sizing & coloring
|
|
89
|
+
|
|
90
|
+
```vue
|
|
91
|
+
<Home :size="32" /> <!-- 32×32px -->
|
|
92
|
+
<Home :size="48" color="#d97757" /> <!-- Custom size and color -->
|
|
93
|
+
<Home color="currentColor" /> <!-- Inherits parent text color -->
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Direct icon import (smallest bundle)
|
|
97
|
+
|
|
98
|
+
For the absolute minimum bundle size, import icons directly from the sub-path:
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
import Home from 'reicon-vue/icons/Home';
|
|
102
|
+
import ShieldCheck from 'reicon-vue/icons/ShieldCheck';
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### All SVG attributes are supported
|
|
106
|
+
|
|
107
|
+
Pass any standard SVG attribute — `class`, `style`, `onClick`, `aria-*`, etc.:
|
|
108
|
+
|
|
109
|
+
```vue
|
|
110
|
+
<Home
|
|
111
|
+
:size="48"
|
|
112
|
+
color="red"
|
|
113
|
+
class="my-icon"
|
|
114
|
+
:style="{ marginRight: 8 }"
|
|
115
|
+
@click="console.log('clicked')"
|
|
116
|
+
aria-label="Home"
|
|
117
|
+
/>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Props
|
|
123
|
+
|
|
124
|
+
| Prop | Type | Default | Description |
|
|
125
|
+
|------|------|---------|-------------|
|
|
126
|
+
| `size` | `number | string` | `24` | Icon width & height (number = px) |
|
|
127
|
+
| `color` | `string` | — | Primary icon stroke/fill color. Leave unset to use CSS class. |
|
|
128
|
+
| `weight` | `'Outline' | 'Filled'` | `'Outline'` | Icon style variant |
|
|
129
|
+
| `strokeWidth` | `number | string` | — | Override the default stroke width |
|
|
130
|
+
| `class` | `string | array | object` | — | Additional CSS class on the `<svg>` element |
|
|
131
|
+
| `style` | `string | array | object` | — | Additional inline styles |
|
|
132
|
+
|
|
133
|
+
Any valid SVG attribute (e.g. `id`, `aria-*`) is forwarded to the underlying `<svg>` element.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Tree-shaking
|
|
138
|
+
|
|
139
|
+
Every icon is a standalone ES module. Modern bundlers — **Vite**, **Webpack**, **Rollup**, **esbuild** — automatically tree-shake unused icons, keeping only what you import.
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
// ✅ Only Home is included in your production bundle
|
|
143
|
+
import { Home } from 'reicon-vue';
|
|
144
|
+
|
|
145
|
+
// ✅ Even smaller — direct path import skips the barrel file entirely
|
|
146
|
+
import Home from 'reicon-vue/icons/Home';
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The package is marked `"sideEffects": false` for optimal dead-code elimination.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Icon Names
|
|
154
|
+
|
|
155
|
+
Icons use **PascalCase**, derived from their original kebab-case file names:
|
|
156
|
+
|
|
157
|
+
| Original name | PascalCase import |
|
|
158
|
+
|---------------|-------------------|
|
|
159
|
+
| `home` | `Home` |
|
|
160
|
+
| `shield-check` | `ShieldCheck` |
|
|
161
|
+
| `alt-arrow-down` | `AltArrowDown` |
|
|
162
|
+
| `shopping-cart` | `ShoppingCart` |
|
|
163
|
+
| `user-circle` | `UserCircle` |
|
|
164
|
+
|
|
165
|
+
Browse and search all 2674+ icons at <a href="https://reicon.dev">reicon.dev</a>.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## TypeScript
|
|
170
|
+
|
|
171
|
+
Full type declarations ship with the package — no separate `@types/` installation needed.
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import { Home, type IconProps, type IconWeight } from 'reicon-vue';
|
|
175
|
+
|
|
176
|
+
const weight: IconWeight = 'Filled';
|
|
177
|
+
const props: IconProps = { size: 32, color: '#d97757', weight };
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Exported types
|
|
181
|
+
|
|
182
|
+
| Type | Description |
|
|
183
|
+
|------|-------------|
|
|
184
|
+
| `IconProps` | Combined icon props + Vue SVG attributes |
|
|
185
|
+
| `IconWeight` | `'Outline' | 'Filled'` |
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Features
|
|
190
|
+
|
|
191
|
+
- **2674+ icons** — Handcrafted, pixel-perfect SVGs across a wide range of categories
|
|
192
|
+
- **Two weights** — Outline and Filled, with consistent 24×24 grid alignment
|
|
193
|
+
- **Tree-shakeable** — Import only what you use; every icon is a standalone ES module
|
|
194
|
+
- **Zero dependencies** — No runtime overhead beyond Vue itself
|
|
195
|
+
- **TypeScript-ready** — Full type declarations included, no extra packages needed
|
|
196
|
+
- **SVG attribute passthrough** — All standard SVG props (`class`, `style`, `aria-*`, etc.) are forwarded
|
|
197
|
+
- **MIT licensed** — Free for personal and commercial use
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Related packages
|
|
202
|
+
|
|
203
|
+
| Package | Description |
|
|
204
|
+
|---------|-------------|
|
|
205
|
+
| [`reicon`](https://npmjs.com/package/reicon) | Core vanilla JS + CDN runtime. No framework required. |
|
|
206
|
+
| [`reicon-react`](https://npmjs.com/package/reicon-react) | React components for 2674+ icons. |
|
|
207
|
+
| [`reicon-vue`](https://npmjs.com/package/reicon-vue) | **You are here.** Vue 3 components for 2674+ icons. |
|
|
208
|
+
| [`reicon-svelte`](https://npmjs.com/package/reicon-svelte) | Svelte components for 2674+ icons. |
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Links
|
|
213
|
+
|
|
214
|
+
- 🌐 Website: [reicon.dev](https://reicon.dev)
|
|
215
|
+
- 📖 Documentation: [reicon.dev/docs](https://reicon.dev/docs)
|
|
216
|
+
- 📦 npm: [npmjs.com/package/reicon-vue](https://npmjs.com/package/reicon-vue)
|
|
217
|
+
- 🐙 GitHub: [github.com/dqev/reicon](https://github.com/dqev/reicon)
|
|
218
|
+
- 🐛 Issues: [github.com/dqev/reicon/issues](https://github.com/dqev/reicon/issues)
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT © [Dev Chauhan](https://devchauhan.in)
|
|
225
|
+
|
|
226
|
+
Free to use in personal and commercial projects. Attribution is appreciated but not required.
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vezham/icons-vue",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Vue icon components for Reicon.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/vezham/reicon",
|
|
9
|
+
"directory": "packages/icons-vue"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/vezham/reicon/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://vezham.com",
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"vue": "^3.0.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"vue": "^3.0.0"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "node scripts/build.cjs"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* build.cjs — Generates the `reicon-vue` Vue 3 package from icondata.json
|
|
4
|
+
*
|
|
5
|
+
* Usage: node packages/icons-vue/scripts/build.cjs (or: npm run build:vue)
|
|
6
|
+
*
|
|
7
|
+
* Output:
|
|
8
|
+
* src/icons/ Individual Vue icon files and type declarations (git-ignored)
|
|
9
|
+
* src/index.js Barrel ESM exports (git-ignored)
|
|
10
|
+
* src/index.d.ts Barrel TypeScript declarations (git-ignored)
|
|
11
|
+
* dist/ Standard NPM package ready to publish (git-ignored)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
|
|
17
|
+
// ── paths ──────────────────────────────────────────────────────────────────
|
|
18
|
+
const DATA_PATH = path.join(__dirname, '..', '..', '..', 'data', 'icon-data.json');
|
|
19
|
+
const TAGS_PATH = path.join(__dirname, '..', '..', '..', 'data', 'icon-tags.json');
|
|
20
|
+
const SRC = path.join(__dirname, '..', 'src');
|
|
21
|
+
const DIST = path.join(__dirname, '..', 'dist');
|
|
22
|
+
|
|
23
|
+
// ── weight short keys ──────────────────────────────────────────────────────
|
|
24
|
+
const W_KEY = { Filled: 'F', Outline: 'O' };
|
|
25
|
+
|
|
26
|
+
// ── helpers ────────────────────────────────────────────────────────────────
|
|
27
|
+
function toPascalCase(str) {
|
|
28
|
+
return str
|
|
29
|
+
.split('-')
|
|
30
|
+
.map(s => s.charAt(0).toUpperCase() + s.slice(1))
|
|
31
|
+
.join('');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function stripSvgWrapper(code) {
|
|
35
|
+
if (!code) return '';
|
|
36
|
+
return code.replace(/^<svg[^>]*>/, '').replace(/<\/svg>\s*$/, '').trim();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Fix hardcoded fill="white" → currentColor so user color prop works correctly.
|
|
40
|
+
function rewriteColors(svg) {
|
|
41
|
+
return svg.replace(/fill="white"/g, 'fill="currentColor"');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function escapeForJS(s) {
|
|
45
|
+
return s.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$\{/g, '\\${');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Build a base64 data URI for an inline SVG preview (shown in IDE hover).
|
|
50
|
+
*/
|
|
51
|
+
function buildPreviewDataUri(weights) {
|
|
52
|
+
const inner = weights['O'] || weights['F'] || '';
|
|
53
|
+
if (!inner) return '';
|
|
54
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">${inner}</svg>`
|
|
55
|
+
.replace(/currentColor/g, '#e4e4e7');
|
|
56
|
+
return `data:image/svg+xml;base64,${Buffer.from(svg).toString('base64')}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ── read data ──────────────────────────────────────────────────────────────
|
|
60
|
+
console.log('Reading icondata.json …');
|
|
61
|
+
const data = JSON.parse(fs.readFileSync(DATA_PATH, 'utf-8'));
|
|
62
|
+
|
|
63
|
+
let TAGS = {};
|
|
64
|
+
if (fs.existsSync(TAGS_PATH)) {
|
|
65
|
+
TAGS = JSON.parse(fs.readFileSync(TAGS_PATH, 'utf-8'));
|
|
66
|
+
console.log(`Read ${Object.keys(TAGS).length} tag entries`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ── collect icons ──────────────────────────────────────────────────────────
|
|
70
|
+
const icons = [];
|
|
71
|
+
const pascalLowerSet = new Set();
|
|
72
|
+
|
|
73
|
+
for (const [catKey, catData] of Object.entries(data.categories || {})) {
|
|
74
|
+
for (const [iconKey, icon] of Object.entries(catData.icons || {})) {
|
|
75
|
+
let pascal = toPascalCase(iconKey);
|
|
76
|
+
|
|
77
|
+
if (pascalLowerSet.has(pascal.toLowerCase())) {
|
|
78
|
+
pascal += toPascalCase(catKey);
|
|
79
|
+
}
|
|
80
|
+
pascalLowerSet.add(pascal.toLowerCase());
|
|
81
|
+
|
|
82
|
+
const weights = {};
|
|
83
|
+
for (const [wName, wData] of Object.entries(icon.weights || {})) {
|
|
84
|
+
const short = W_KEY[wName];
|
|
85
|
+
if (short && wData.code) {
|
|
86
|
+
weights[short] = rewriteColors(stripSvgWrapper(wData.code));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (Object.keys(weights).length > 0) {
|
|
91
|
+
icons.push({
|
|
92
|
+
kebab: iconKey,
|
|
93
|
+
pascal,
|
|
94
|
+
category: catKey,
|
|
95
|
+
weights,
|
|
96
|
+
tags: TAGS[iconKey] || icon.description || [],
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
icons.sort((a, b) => a.pascal.localeCompare(b.pascal));
|
|
103
|
+
console.log(`Found ${icons.length} icons`);
|
|
104
|
+
|
|
105
|
+
// ── clean & prepare src/icons ──────────────────────────────────────────────
|
|
106
|
+
fs.rmSync(path.join(SRC, 'icons'), { recursive: true, force: true });
|
|
107
|
+
fs.mkdirSync(path.join(SRC, 'icons'), { recursive: true });
|
|
108
|
+
|
|
109
|
+
// ── individual icon files ──────────────────────────────────────────────────
|
|
110
|
+
console.log('Generating Vue component files in src/icons/ …');
|
|
111
|
+
|
|
112
|
+
const barrelExports = [];
|
|
113
|
+
const dtsExports = [];
|
|
114
|
+
|
|
115
|
+
for (const icon of icons) {
|
|
116
|
+
const wEntries = Object.entries(icon.weights)
|
|
117
|
+
.map(([k, v]) => ` ${k}: \`${escapeForJS(v)}\``)
|
|
118
|
+
.join(',\n');
|
|
119
|
+
|
|
120
|
+
const previewUri = buildPreviewDataUri(icon.weights);
|
|
121
|
+
const kebab = icon.kebab;
|
|
122
|
+
|
|
123
|
+
// ── icon .js file ──
|
|
124
|
+
const iconJS = `import createIcon from '../createIcon.js';
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @component
|
|
128
|
+
* @name ${icon.pascal}
|
|
129
|
+
* @description Reicon Vue icon component, renders an SVG Element.
|
|
130
|
+
* @preview  - https://reicon.dev/icons/${kebab}
|
|
131
|
+
* @see https://reicon.dev/docs — Documentation
|
|
132
|
+
*/
|
|
133
|
+
const ${icon.pascal} = createIcon('${icon.pascal}', {
|
|
134
|
+
${wEntries}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export { ${icon.pascal} };
|
|
138
|
+
export default ${icon.pascal};
|
|
139
|
+
`;
|
|
140
|
+
|
|
141
|
+
fs.writeFileSync(path.join(SRC, 'icons', `${icon.pascal}.js`), iconJS);
|
|
142
|
+
|
|
143
|
+
// ── icon .d.ts file ──
|
|
144
|
+
const iconDTS = `import { IconComponent } from '../createIcon';
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @component
|
|
148
|
+
* @name ${icon.pascal}
|
|
149
|
+
* @description Reicon Vue icon component, renders an SVG Element.
|
|
150
|
+
* @preview  - https://reicon.dev/icons/${kebab}
|
|
151
|
+
* @see https://reicon.dev/docs — Documentation
|
|
152
|
+
*/
|
|
153
|
+
declare const ${icon.pascal}: IconComponent;
|
|
154
|
+
export { ${icon.pascal} };
|
|
155
|
+
export default ${icon.pascal};
|
|
156
|
+
`;
|
|
157
|
+
|
|
158
|
+
fs.writeFileSync(path.join(SRC, 'icons', `${icon.pascal}.d.ts`), iconDTS);
|
|
159
|
+
|
|
160
|
+
barrelExports.push(`export { ${icon.pascal} } from './icons/${icon.pascal}.js';`);
|
|
161
|
+
dtsExports.push(`export { ${icon.pascal} } from './icons/${icon.pascal}.js';`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ── index.js (ESM barrel in src/) ──────────────────────────────────────────
|
|
165
|
+
const indexJS = `// Auto-generated barrel — do not edit
|
|
166
|
+
export { createIcon } from './createIcon.js';
|
|
167
|
+
|
|
168
|
+
${barrelExports.join('\n')}
|
|
169
|
+
`;
|
|
170
|
+
|
|
171
|
+
fs.writeFileSync(path.join(SRC, 'index.js'), indexJS);
|
|
172
|
+
|
|
173
|
+
// ── index.d.ts (types in src/) ─────────────────────────────────────────────
|
|
174
|
+
const indexDTS = `// Auto-generated — do not edit
|
|
175
|
+
export { createIcon, IconProps, IconWeight, IconComponent } from './createIcon';
|
|
176
|
+
|
|
177
|
+
${dtsExports.join('\n')}
|
|
178
|
+
`;
|
|
179
|
+
|
|
180
|
+
fs.writeFileSync(path.join(SRC, 'index.d.ts'), indexDTS);
|
|
181
|
+
|
|
182
|
+
// ── recreate src/icons/.gitkeep ────────────────────────────────────────────
|
|
183
|
+
fs.writeFileSync(path.join(SRC, 'icons', '.gitkeep'), '# Keep directory in Git\n');
|
|
184
|
+
|
|
185
|
+
// ── clean & prepare dist ───────────────────────────────────────────────────
|
|
186
|
+
console.log('Preparing production build in dist/ …');
|
|
187
|
+
fs.rmSync(DIST, { recursive: true, force: true });
|
|
188
|
+
fs.mkdirSync(path.join(DIST, 'icons'), { recursive: true });
|
|
189
|
+
|
|
190
|
+
// ── copy src files to dist ─────────────────────────────────────────────────
|
|
191
|
+
fs.copyFileSync(path.join(SRC, 'createIcon.js'), path.join(DIST, 'createIcon.js'));
|
|
192
|
+
fs.copyFileSync(path.join(SRC, 'createIcon.d.ts'), path.join(DIST, 'createIcon.d.ts'));
|
|
193
|
+
fs.copyFileSync(path.join(SRC, 'index.js'), path.join(DIST, 'index.js'));
|
|
194
|
+
fs.copyFileSync(path.join(SRC, 'index.d.ts'), path.join(DIST, 'index.d.ts'));
|
|
195
|
+
|
|
196
|
+
for (const icon of icons) {
|
|
197
|
+
fs.copyFileSync(path.join(SRC, 'icons', `${icon.pascal}.js`), path.join(DIST, 'icons', `${icon.pascal}.js`));
|
|
198
|
+
fs.copyFileSync(path.join(SRC, 'icons', `${icon.pascal}.d.ts`), path.join(DIST, 'icons', `${icon.pascal}.d.ts`));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ── package.json ───────────────────────────────────────────────────────────
|
|
202
|
+
const srcPkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
203
|
+
const pkg = {
|
|
204
|
+
name: srcPkg.name,
|
|
205
|
+
version: srcPkg.version,
|
|
206
|
+
type: 'module',
|
|
207
|
+
description:
|
|
208
|
+
`Vue 3 icon components for ${icons.length}+ icons in 2 weights (Outline & Filled). Tree-shakeable, TypeScript-ready.`,
|
|
209
|
+
main: './index.js',
|
|
210
|
+
module: './index.js',
|
|
211
|
+
types: './index.d.ts',
|
|
212
|
+
exports: {
|
|
213
|
+
'.': {
|
|
214
|
+
import: './index.js',
|
|
215
|
+
types: './index.d.ts',
|
|
216
|
+
},
|
|
217
|
+
'./icons/*': {
|
|
218
|
+
import: './icons/*.js',
|
|
219
|
+
types: './icons/*.d.ts',
|
|
220
|
+
},
|
|
221
|
+
'./createIcon': {
|
|
222
|
+
import: './createIcon.js',
|
|
223
|
+
types: './createIcon.d.ts',
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
sideEffects: false,
|
|
227
|
+
files: ['index.js', 'index.d.ts', 'createIcon.js', 'createIcon.d.ts', 'icons/', 'README.md'],
|
|
228
|
+
peerDependencies: {
|
|
229
|
+
vue: '^3.0.0',
|
|
230
|
+
},
|
|
231
|
+
keywords: [
|
|
232
|
+
'icons',
|
|
233
|
+
'vue',
|
|
234
|
+
'vue3',
|
|
235
|
+
'vue-icons',
|
|
236
|
+
'svg-icons',
|
|
237
|
+
'icon-library',
|
|
238
|
+
'reicon',
|
|
239
|
+
'outline',
|
|
240
|
+
'filled',
|
|
241
|
+
'tree-shakeable',
|
|
242
|
+
'typescript',
|
|
243
|
+
],
|
|
244
|
+
author: {
|
|
245
|
+
name: 'devchauhan',
|
|
246
|
+
email: 'dev@devchauhan.in',
|
|
247
|
+
url: 'https://devchauhan.in',
|
|
248
|
+
},
|
|
249
|
+
license: 'MIT',
|
|
250
|
+
repository: { type: 'git', url: 'https://github.com/vezham/reicon', directory: 'packages/icons-vue' },
|
|
251
|
+
bugs: { url: 'https://github.com/vezham/reicon/issues' },
|
|
252
|
+
homepage: 'https://vezham.com',
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
fs.writeFileSync(path.join(DIST, 'package.json'), JSON.stringify(pkg, null, 2) + '\n');
|
|
256
|
+
|
|
257
|
+
// ── README.md ──────────────────────────────────────────────────────────────
|
|
258
|
+
const readme = `<p align="center">
|
|
259
|
+
<a href="https://reicon.dev">
|
|
260
|
+
<img src="https://reicon.dev/readme-banner.png" alt="Reicon Vue — SVG Icon Library for Vue 3" width="100%" />
|
|
261
|
+
</a>
|
|
262
|
+
</p>
|
|
263
|
+
|
|
264
|
+
<p align="center">
|
|
265
|
+
<a href="https://npmjs.com/package/reicon-vue"><img src="https://img.shields.io/npm/v/reicon-vue?color=black&label=npm" alt="npm version" /></a>
|
|
266
|
+
<a href="https://npmjs.com/package/reicon-vue"><img src="https://img.shields.io/npm/dm/reicon-vue?color=black&label=downloads" alt="npm downloads" /></a>
|
|
267
|
+
<a href="https://github.com/dqev/reicon/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-black" alt="MIT License" /></a>
|
|
268
|
+
<a href="https://reicon.dev"><img src="https://img.shields.io/badge/docs-reicon.dev-black" alt="Documentation" /></a>
|
|
269
|
+
<a href="https://github.com/dqev/reicon"><img src="https://img.shields.io/badge/github-dqev/reicon-black" alt="GitHub" /></a>
|
|
270
|
+
</p>
|
|
271
|
+
|
|
272
|
+
<h1 align="center">Reicon Vue</h1>
|
|
273
|
+
|
|
274
|
+
<p align="center">
|
|
275
|
+
<b>${icons.length}+ pixel-perfect SVG icons</b> • Outline & Filled weights • Vue 3 component wrapper • Zero dependencies • MIT Licensed
|
|
276
|
+
</p>
|
|
277
|
+
|
|
278
|
+
<p align="center">
|
|
279
|
+
<a href="#install">Install</a> •
|
|
280
|
+
<a href="#usage">Usage</a> •
|
|
281
|
+
<a href="#props">Props</a> •
|
|
282
|
+
<a href="#tree-shaking">Tree-shaking</a> •
|
|
283
|
+
<a href="#icon-names">Icon Names</a> •
|
|
284
|
+
<a href="#typescript">TypeScript</a>
|
|
285
|
+
</p>
|
|
286
|
+
|
|
287
|
+
**Reicon Vue** is the official Vue 3 package for <a href="https://reicon.dev">Reicon</a> — a free, open-source SVG icon library featuring ${icons.length}+ handcrafted, grid-aligned icons. Every component is tree-shakeable, fully TypeScript-ready, and ships with zero dependencies.
|
|
288
|
+
|
|
289
|
+
| 🔗 Resource | Link |
|
|
290
|
+
|---|---|
|
|
291
|
+
| 🌐 Website & icon browser | [reicon.dev](https://reicon.dev) |
|
|
292
|
+
| 📖 Documentation | [reicon.dev/docs](https://reicon.dev/docs) |
|
|
293
|
+
| 📦 Core package (vanilla JS) | [reicon](https://npmjs.com/package/reicon) |
|
|
294
|
+
| 🎨 Figma plugin | [reicon.dev/docs/figma](https://reicon.dev/docs/figma) |
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Install
|
|
299
|
+
|
|
300
|
+
\`\`\`bash
|
|
301
|
+
npm i reicon-vue
|
|
302
|
+
# or
|
|
303
|
+
bun add reicon-vue
|
|
304
|
+
# or
|
|
305
|
+
yarn add reicon-vue
|
|
306
|
+
\`\`\`
|
|
307
|
+
|
|
308
|
+
<details>
|
|
309
|
+
<summary><b>Requirements</b></summary>
|
|
310
|
+
|
|
311
|
+
- **Vue** ≥ 3.0 (Composition API)
|
|
312
|
+
- No other dependencies required.
|
|
313
|
+
|
|
314
|
+
</details>
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Usage
|
|
319
|
+
|
|
320
|
+
### Basic
|
|
321
|
+
|
|
322
|
+
\`\`\`vue
|
|
323
|
+
<script setup>
|
|
324
|
+
import { Home, ShieldCheck, AltArrowDown } from 'reicon-vue';
|
|
325
|
+
</script>
|
|
326
|
+
|
|
327
|
+
<template>
|
|
328
|
+
<div>
|
|
329
|
+
<Home />
|
|
330
|
+
<ShieldCheck :size="32" color="#d97757" />
|
|
331
|
+
<AltArrowDown weight="Filled" />
|
|
332
|
+
</div>
|
|
333
|
+
</template>
|
|
334
|
+
\`\`\`
|
|
335
|
+
|
|
336
|
+
### Weights
|
|
337
|
+
|
|
338
|
+
Every icon ships in two weights — **Outline** (default) and **Filled**:
|
|
339
|
+
|
|
340
|
+
\`\`\`vue
|
|
341
|
+
<Home /> <!-- Outline (default) -->
|
|
342
|
+
<Home weight="Filled" /> <!-- Filled -->
|
|
343
|
+
\`\`\`
|
|
344
|
+
|
|
345
|
+
### Sizing & coloring
|
|
346
|
+
|
|
347
|
+
\`\`\`vue
|
|
348
|
+
<Home :size="32" /> <!-- 32×32px -->
|
|
349
|
+
<Home :size="48" color="#d97757" /> <!-- Custom size and color -->
|
|
350
|
+
<Home color="currentColor" /> <!-- Inherits parent text color -->
|
|
351
|
+
\`\`\`
|
|
352
|
+
|
|
353
|
+
### Direct icon import (smallest bundle)
|
|
354
|
+
|
|
355
|
+
For the absolute minimum bundle size, import icons directly from the sub-path:
|
|
356
|
+
|
|
357
|
+
\`\`\`js
|
|
358
|
+
import Home from 'reicon-vue/icons/Home';
|
|
359
|
+
import ShieldCheck from 'reicon-vue/icons/ShieldCheck';
|
|
360
|
+
\`\`\`
|
|
361
|
+
|
|
362
|
+
### All SVG attributes are supported
|
|
363
|
+
|
|
364
|
+
Pass any standard SVG attribute — \`class\`, \`style\`, \`onClick\`, \`aria-*\`, etc.:
|
|
365
|
+
|
|
366
|
+
\`\`\`vue
|
|
367
|
+
<Home
|
|
368
|
+
:size="48"
|
|
369
|
+
color="red"
|
|
370
|
+
class="my-icon"
|
|
371
|
+
:style="{ marginRight: 8 }"
|
|
372
|
+
@click="console.log('clicked')"
|
|
373
|
+
aria-label="Home"
|
|
374
|
+
/>
|
|
375
|
+
\`\`\`
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## Props
|
|
380
|
+
|
|
381
|
+
| Prop | Type | Default | Description |
|
|
382
|
+
|------|------|---------|-------------|
|
|
383
|
+
| \`size\` | \`number | string\` | \`24\` | Icon width & height (number = px) |
|
|
384
|
+
| \`color\` | \`string\` | — | Primary icon stroke/fill color. Leave unset to use CSS class. |
|
|
385
|
+
| \`weight\` | \`'Outline' | 'Filled'\` | \`'Outline'\` | Icon style variant |
|
|
386
|
+
| \`strokeWidth\` | \`number | string\` | — | Override the default stroke width |
|
|
387
|
+
| \`class\` | \`string | array | object\` | — | Additional CSS class on the \`<svg>\` element |
|
|
388
|
+
| \`style\` | \`string | array | object\` | — | Additional inline styles |
|
|
389
|
+
|
|
390
|
+
Any valid SVG attribute (e.g. \`id\`, \`aria-*\`) is forwarded to the underlying \`<svg>\` element.
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## Tree-shaking
|
|
395
|
+
|
|
396
|
+
Every icon is a standalone ES module. Modern bundlers — **Vite**, **Webpack**, **Rollup**, **esbuild** — automatically tree-shake unused icons, keeping only what you import.
|
|
397
|
+
|
|
398
|
+
\`\`\`js
|
|
399
|
+
// ✅ Only Home is included in your production bundle
|
|
400
|
+
import { Home } from 'reicon-vue';
|
|
401
|
+
|
|
402
|
+
// ✅ Even smaller — direct path import skips the barrel file entirely
|
|
403
|
+
import Home from 'reicon-vue/icons/Home';
|
|
404
|
+
\`\`\`
|
|
405
|
+
|
|
406
|
+
The package is marked \`"sideEffects": false\` for optimal dead-code elimination.
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## Icon Names
|
|
411
|
+
|
|
412
|
+
Icons use **PascalCase**, derived from their original kebab-case file names:
|
|
413
|
+
|
|
414
|
+
| Original name | PascalCase import |
|
|
415
|
+
|---------------|-------------------|
|
|
416
|
+
| \`home\` | \`Home\` |
|
|
417
|
+
| \`shield-check\` | \`ShieldCheck\` |
|
|
418
|
+
| \`alt-arrow-down\` | \`AltArrowDown\` |
|
|
419
|
+
| \`shopping-cart\` | \`ShoppingCart\` |
|
|
420
|
+
| \`user-circle\` | \`UserCircle\` |
|
|
421
|
+
|
|
422
|
+
Browse and search all ${icons.length}+ icons at <a href="https://reicon.dev">reicon.dev</a>.
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## TypeScript
|
|
427
|
+
|
|
428
|
+
Full type declarations ship with the package — no separate \`@types/\` installation needed.
|
|
429
|
+
|
|
430
|
+
\`\`\`ts
|
|
431
|
+
import { Home, type IconProps, type IconWeight } from 'reicon-vue';
|
|
432
|
+
|
|
433
|
+
const weight: IconWeight = 'Filled';
|
|
434
|
+
const props: IconProps = { size: 32, color: '#d97757', weight };
|
|
435
|
+
\`\`\`
|
|
436
|
+
|
|
437
|
+
### Exported types
|
|
438
|
+
|
|
439
|
+
| Type | Description |
|
|
440
|
+
|------|-------------|
|
|
441
|
+
| \`IconProps\` | Combined icon props + Vue SVG attributes |
|
|
442
|
+
| \`IconWeight\` | \`'Outline' | 'Filled'\` |
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## Features
|
|
447
|
+
|
|
448
|
+
- **${icons.length}+ icons** — Handcrafted, pixel-perfect SVGs across a wide range of categories
|
|
449
|
+
- **Two weights** — Outline and Filled, with consistent 24×24 grid alignment
|
|
450
|
+
- **Tree-shakeable** — Import only what you use; every icon is a standalone ES module
|
|
451
|
+
- **Zero dependencies** — No runtime overhead beyond Vue itself
|
|
452
|
+
- **TypeScript-ready** — Full type declarations included, no extra packages needed
|
|
453
|
+
- **SVG attribute passthrough** — All standard SVG props (\`class\`, \`style\`, \`aria-*\`, etc.) are forwarded
|
|
454
|
+
- **MIT licensed** — Free for personal and commercial use
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## Related packages
|
|
459
|
+
|
|
460
|
+
| Package | Description |
|
|
461
|
+
|---------|-------------|
|
|
462
|
+
| [\`reicon\`](https://npmjs.com/package/reicon) | Core vanilla JS + CDN runtime. No framework required. |
|
|
463
|
+
| [\`reicon-react\`](https://npmjs.com/package/reicon-react) | React components for ${icons.length}+ icons. |
|
|
464
|
+
| [\`reicon-vue\`](https://npmjs.com/package/reicon-vue) | **You are here.** Vue 3 components for ${icons.length}+ icons. |
|
|
465
|
+
| [\`reicon-svelte\`](https://npmjs.com/package/reicon-svelte) | Svelte components for ${icons.length}+ icons. |
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
## Links
|
|
470
|
+
|
|
471
|
+
- 🌐 Website: [reicon.dev](https://reicon.dev)
|
|
472
|
+
- 📖 Documentation: [reicon.dev/docs](https://reicon.dev/docs)
|
|
473
|
+
- 📦 npm: [npmjs.com/package/reicon-vue](https://npmjs.com/package/reicon-vue)
|
|
474
|
+
- 🐙 GitHub: [github.com/dqev/reicon](https://github.com/dqev/reicon)
|
|
475
|
+
- 🐛 Issues: [github.com/dqev/reicon/issues](https://github.com/dqev/reicon/issues)
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
## License
|
|
480
|
+
|
|
481
|
+
MIT © [Dev Chauhan](https://devchauhan.in)
|
|
482
|
+
|
|
483
|
+
Free to use in personal and commercial projects. Attribution is appreciated but not required.
|
|
484
|
+
`;
|
|
485
|
+
|
|
486
|
+
fs.writeFileSync(path.join(DIST, 'README.md'), readme);
|
|
487
|
+
fs.writeFileSync(path.join(__dirname, '..', 'README.md'), readme);
|
|
488
|
+
|
|
489
|
+
// ── icon name map (for documentation / search) ────────────────────────────
|
|
490
|
+
const nameMap = {};
|
|
491
|
+
for (const icon of icons) {
|
|
492
|
+
nameMap[icon.kebab] = icon.pascal;
|
|
493
|
+
}
|
|
494
|
+
fs.writeFileSync(path.join(DIST, 'icon-names.json'), JSON.stringify(nameMap, null, 2));
|
|
495
|
+
|
|
496
|
+
// ── summary ────────────────────────────────────────────────────────────────
|
|
497
|
+
const totalFiles = (icons.length * 2) + 5;
|
|
498
|
+
console.log(`\nDone!`);
|
|
499
|
+
console.log(` Icons: ${icons.length}`);
|
|
500
|
+
console.log(` Weights: Outline + Filled`);
|
|
501
|
+
console.log(` Files: ${totalFiles}`);
|
|
502
|
+
console.log(` Output: ${DIST}`);
|
|
503
|
+
console.log(`\nTo publish:`);
|
|
504
|
+
console.log(` cd dist && npm publish --access public`);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DefineComponent, ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
export type IconWeight = 'Filled' | 'Outline';
|
|
4
|
+
|
|
5
|
+
export declare const iconProps: {
|
|
6
|
+
color: { type: StringConstructor; default: undefined };
|
|
7
|
+
size: { type: (NumberConstructor | StringConstructor)[]; default: 24 };
|
|
8
|
+
weight: { type: StringConstructor; default: 'Outline'; validator: (v: string) => boolean };
|
|
9
|
+
strokeWidth: { type: (NumberConstructor | StringConstructor)[]; default: undefined };
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type IconProps = Partial<ExtractPropTypes<typeof iconProps>>;
|
|
13
|
+
|
|
14
|
+
export type IconComponent = DefineComponent<{
|
|
15
|
+
/** Primary color. Default: inherits from CSS */
|
|
16
|
+
color?: string;
|
|
17
|
+
/** Icon size (px when number). Default: `24` */
|
|
18
|
+
size?: number | string;
|
|
19
|
+
/** Icon weight / style. Default: `Outline` */
|
|
20
|
+
weight?: IconWeight;
|
|
21
|
+
/** Override stroke-width on stroked weights */
|
|
22
|
+
strokeWidth?: number | string;
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
export declare function createIcon(
|
|
26
|
+
displayName: string,
|
|
27
|
+
iconData: Partial<Record<string, string>>,
|
|
28
|
+
): IconComponent;
|
|
29
|
+
|
|
30
|
+
export default createIcon;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { defineComponent, h, computed } from 'vue';
|
|
2
|
+
|
|
3
|
+
const W_MAP = { Filled: 'F', Outline: 'O' };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Factory that builds a Vue 3 icon component.
|
|
7
|
+
* @param {string} displayName PascalCase icon name
|
|
8
|
+
* @param {Object} iconData { F?: string, O?: string }
|
|
9
|
+
* @returns {import('vue').DefineComponent}
|
|
10
|
+
*/
|
|
11
|
+
const createIcon = (displayName, iconData) => {
|
|
12
|
+
return defineComponent({
|
|
13
|
+
name: displayName,
|
|
14
|
+
inheritAttrs: false,
|
|
15
|
+
props: {
|
|
16
|
+
/** Primary icon color. Default: `currentColor` */
|
|
17
|
+
color: { type: String, default: undefined },
|
|
18
|
+
/** Icon size (number = px, string = any CSS unit). Default: `24` */
|
|
19
|
+
size: { type: [Number, String], default: 24 },
|
|
20
|
+
/** Icon weight / style: `'Outline'` | `'Filled'`. Default: `'Outline'` */
|
|
21
|
+
weight: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: 'Outline',
|
|
24
|
+
validator: (v) => ['Outline', 'Filled'].includes(String(v)),
|
|
25
|
+
},
|
|
26
|
+
/** Override stroke-width on stroked weights */
|
|
27
|
+
strokeWidth: { type: [Number, String], default: undefined },
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* @param {any} props
|
|
31
|
+
* @param {import('vue').SetupContext} context
|
|
32
|
+
*/
|
|
33
|
+
setup(props, { attrs }) {
|
|
34
|
+
const svgHtml = computed(() => {
|
|
35
|
+
const key = W_MAP[props.weight] || 'O';
|
|
36
|
+
/** @type {Record<string, string>} */
|
|
37
|
+
const data = iconData;
|
|
38
|
+
const firstKey = Object.keys(data)[0] || '';
|
|
39
|
+
let html = data[key] || (firstKey ? data[firstKey] : '') || '';
|
|
40
|
+
if (props.strokeWidth != null) {
|
|
41
|
+
html = html.replace(/stroke-width="[^"]*"/g, 'stroke-width="' + props.strokeWidth + '"');
|
|
42
|
+
}
|
|
43
|
+
return html;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return () => {
|
|
47
|
+
const { class: userClass, style: userStyle, ...restAttrs } = attrs;
|
|
48
|
+
|
|
49
|
+
return h('svg', {
|
|
50
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
51
|
+
width: props.size,
|
|
52
|
+
height: props.size,
|
|
53
|
+
viewBox: '0 0 24 24',
|
|
54
|
+
fill: 'none',
|
|
55
|
+
class: ['reicon', userClass],
|
|
56
|
+
style: props.color != null ? [{ color: props.color }, userStyle] : userStyle,
|
|
57
|
+
innerHTML: svgHtml.value,
|
|
58
|
+
...restAttrs,
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { createIcon };
|
|
66
|
+
export default createIcon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Keep directory in Git
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"moduleResolution": "bundler",
|
|
4
|
+
"target": "es2022",
|
|
5
|
+
"module": "es2022",
|
|
6
|
+
"lib": ["es2022", "dom"],
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"checkJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"baseUrl": ".",
|
|
12
|
+
"paths": {
|
|
13
|
+
"vue": ["../../node_modules/vue"]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*"]
|
|
17
|
+
}
|